package pinger

import (
	"encoding/binary"
	"time"
)

// timeToBytes
func timeToBytes(t time.Time) []byte {
	data := make([]byte, 8)
	binary.BigEndian.PutUint64(data, uint64(t.UnixNano()))
	return data
}

// bytesToTime
func bytesToTime(bytes []byte) time.Time {
	nsec := int64(binary.BigEndian.Uint64(bytes))
	return time.Unix(nsec/1000000000, nsec%1000000000)
}
